package cn.com.headfree.point.controller;

import cn.com.headfree.entity.TPersonYearPointDetail;
import cn.com.headfree.point.service.ISalaryUserDataInfoService;
import cn.com.headfree.point.service.PersonYearPointDetailService;
import cn.com.headfree.vo.TPersonYearPointDetailVo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Description: TODO
 * @Author wcSun
 * @Date 2021/6/30
 **/
@Controller
@RequestMapping(value = "/test", produces = "application/json;charset=UTF-8")
public class TestController {

    @Autowired
    private ISalaryUserDataInfoService salaryUserDataInfoService;

    @Autowired
    private PersonYearPointDetailService personYearPointDetailService;

    /**
     * 薪档数据关联
     */
    @RequestMapping("/salaryto")
    @ResponseBody
    public String pointsalary(String orgid,Integer year){

        TPersonYearPointDetailVo personYearPointDetail = new TPersonYearPointDetailVo();
        personYearPointDetail.setOrgId(orgid);
        personYearPointDetail.setYear(year);
        List<TPersonYearPointDetail> list = personYearPointDetailService.findPersonYearPointDetailList(personYearPointDetail);

        if(!CollectionUtils.isEmpty(list)){
            list.stream().forEach(item ->{
                salaryUserDataInfoService.salaryUserDataInfoByPointDetail(item);
            });
        }
        return "成功";
    }

}
